package web.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import web.service.CommonService;
import web.service.UserService;

@Controller
@RequestMapping("common")
public class CommonController {

    @Autowired
    private CommonService service;
    @Autowired
    private UserService userService;

    @ResponseBody
    @RequestMapping("information")
    public Map<String, Object> fetchInformation() {
        return service.fetchInformation();
    }

    @ResponseBody
    @RequestMapping("userinfo")
    public Map<String, Object> fetchUserInfo(HttpServletRequest req) {
        Long id = (Long) req.getSession().getAttribute("UID");
        return userService.getUserInfo(id);
    }
}
